﻿// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.

// Write your JavaScript code.
function deleteTodo(i){
    $.ajax({
        url:'Home/Delete',
        type:'POST',
        data:{
            id:i
        },
        success:function (){
            window.location.reload();
        }
    });
}

function populateForm(i){
    $.ajax({
        url:'Home/PopulateForm',
        type:'GET',
        data:{
            id:i
        },
        success:function (response){
            $("#Todo_Name").val(response.name);
            $("#Todo_Id").val(response.id);
            $("#form-button").val("Update Todo");
            $("#form-action").attr("action","/Home/Update");
        }
    })
}